package com.create.myworld.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author zcw
 * rabbitmq配置
 */
@Configuration
public class TopicRabbitConfig {

    public static final  String exchangeName = "topicExchange";

    public static final String normalKey = "normal";

    public static final String dieKey = "die";

    @Bean
    TopicExchange exchange() {
        return new TopicExchange(exchangeName);
    }

    @Bean
    public Queue normalQueue() {
        return new Queue(normalKey);
    }

    @Bean
    public Queue dieQueue() {
        return new Queue(dieKey);
    }

    @Bean
    Binding bindingNormalQueue() {
        return BindingBuilder.bind(normalQueue()).to(exchange()).with(normalKey);
    }

    @Bean
    Binding bindingDieQueue() {
        return BindingBuilder.bind(dieQueue()).to(exchange()).with(dieKey);
    }
}